package work5;

/**
 * @TODO
 * @Author xu
 * 2025/2/26
 */
import java.util.Scanner;
import java.util.Arrays;

public class StringTest {
    public static void main(String[] args) {
        // 练习1
        String email = "chenmin@igeekhome.com";
        for (char c : email.toCharArray()) {
            System.out.print(c + " ");
        }
        System.out.println();

        // 练习2
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个字符串：");
        String input = scanner.nextLine();
        String result = input.substring(0, 1).toUpperCase() + input.substring(1).toLowerCase();
        System.out.println("转换后的字符串：" + result);

        // 练习3
        int[] array = {1, 2, 3, 4, 5};
        StringBuilder sb = new StringBuilder("[");
        for (int i = 0; i < array.length; i++) {
            sb.append(array[i]);
            if (i < array.length - 1) {
                sb.append(", ");
            }
        }
        sb.append("]");
        System.out.println("数组拼接字符串：" + sb.toString());

        scanner.close();
    }
}
